<?php

namespace app\exam\validate;

use think\Validate;

/**
 * 试题验证
 */
class TopicPracticeRecord extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'    =>    ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'topic_id'      => 'require|/^[\d,]+$/',
        'record_id'     => 'require|number',
        'topic_level'   => 'require|in:1,2',
        'is_right'      => 'require|in:0,1',

    ];

    protected $field = [
        'topic_id'     	=> '试题',
        'record_id'     => '试题',
        'topic_level'   => '试题层级',
        'is_right'      => '试题答案结果',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名'    =>    '错误信息'
     *
     * @var array
     */
    protected $message = [
    	'type.in' 		=> '参数错误',
    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'wrong_topic'     	=> ['record_id'],
        'topic_answer'      => ['topic_level','topic_id','is_right'],
    ];


}
